/* APPENDIX FIGURES IN COSAR, GRIECO AND TINTELNOT (2014) 
Inputs: 
- danish_data_9596.dta
- german_data_9596.dta
Outputs: 
- figureA1left.eps
- figureA1right.png
- figureA2.eps
- figureA2.png
- figureA3.eps
- figureA3.png
*/

clear
set scheme s2color
global path "C:\Users\Felix Tintelnot\Dropbox\WindBorder\RestatCGTReplication"


/*  FIGURE 1,2,3: histograms of characteristics */
// Prepare data
use "$path\Data\output_files\danish_data_9596.dta" 
append using "$path\Data\output_files\german_data_9596.dta"
sort year prod germany
label define germany 0 "Denmark" 1 "Germany"
drop if latitude == 0
keep if type =="LAND"

// Figure 1, left panel
quietly hist kw if kw<1100 & denmark ==1,width(200) xlabel(0(200)1000,angle(90)) ylabel(0(0.001)0.004) xtitle(Capacity (KW)) title(Denmark) plotregion(fcolor(white)) graphregion(fcolor(white))
graph export "$path\SummaryStatistics\figures\figureA1left.eps", replace
graph export "$path\SummaryStatistics\figures\figureA1left.png", replace

// Figure 1, right panel
quietly hist kw if kw<1100 & germany ==1, width(200) xlabel(0(200)1000,angle(90)) ylabel(0(0.001)0.004) xtitle(Capacity (KW)) title(Germany) plotregion(fcolor(white)) graphregion(fcolor(white))
graph export "$path\SummaryStatistics\figureA1right.eps", replace
graph export "$path\SummaryStatistics\figureA1right.png", replace

/* Distribution of project size by manufacturer */
keep if prod =="Bonus" | prod =="Vestas" | prod =="Wind World" | prod=="Micon" | prod=="Nordtank" | prod=="Nordex"
gen projc = "GER" if germany==1
replace projc = "DNK" if denmark ==1
gen prod_new = prod + " in " + projc
sort prod_new
set scheme s1color

// Figure 2
hist hub if kw<1100, width(10) xlabel(0(10)70,angle(90)) xtitle(Tower Height (m)) by(prod_new,note(""))
graph export "$path\SummaryStatistics\figures\figureA2.eps", replace
graph export "$path\SummaryStatistics\figures\figureA2.png", replace

// Figure 3
hist kw if kw<1100, width(200) xlabel(0(200)1000,angle(90)) ylabel(0(0.001)0.005,angle(0)) xtitle(Capacity (KW)) by(prod_new,note(""))
graph export "figureA3.eps", replace
graph export "figureA3.png", replace

/* FIGURE 4: price per kw*/
clear
insheet using "$path\Data\original_files\WindTurbinePrices.csv"

drop if price == -9999
gen prpkw = (price/1000)/kw

scatter prpkw kw, xlabel(0(100)1000) xscale(range(0 1000)) ylabel(1(1)5) yscale(range(1 5)) ///
plotregion(fcolor(white)) xtitle(Capacity (KW)) ytitle(Price/KW (1000 Deutsche Mark in 1994 prices)) graphregion(fcolor(white))

graph export "$path\SummaryStatistics\figureA4.eps", replace
graph export "$path\SummaryStatistics\figureA4.png", replace
